package com.eyas.business.controllor.stats;

import com.eyas.business.model.pojo.statsinfo.AdviserParamDTO;
import com.eyas.business.model.pojo.statsinfo.AdviserResultDTO;
import com.eyas.business.model.pojo.statsinfo.IncomeParamDTO;
import com.eyas.business.model.pojo.statsinfo.IncomeResultDTO;
import com.eyas.business.model.pojo.statsinfo.QueryParamDTO;
import com.eyas.business.model.pojo.statsinfo.QueryResultDTO;
import com.eyas.business.service.stats.StatsServiceImpl;
import com.eyas.core.model.page.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * @Auther: 王龙龙
 * @Date: 2019/3/6 15:30
 * @Description:
 */
@Controller
@RequestMapping("/eyas/stats/")
public class StatsAction {
    @Autowired
    private StatsServiceImpl statsService;

    /**教练课时统计
     * @param dto
     * @param page
     * @param limit
     * @return
     */
    @GetMapping("/statsRecordByCoach")
    @ResponseBody
    public PageResult<QueryResultDTO> statsRecordByCoach(QueryParamDTO dto,
                                                            @RequestParam(defaultValue = "1") int page,
                                                            @RequestParam(defaultValue = "10") int limit) {
        PageResult<QueryResultDTO> pageResult = statsService.statsRecordByCoach(dto,page-1,limit);
        return pageResult;
    }
    
    @GetMapping("/statsByLevel")
    @ResponseBody
    public PageResult<QueryResultDTO> statsByLevel(QueryParamDTO dto,
                                                            @RequestParam(defaultValue = "1") int page,
                                                            @RequestParam(defaultValue = "10") int limit) {
        PageResult<QueryResultDTO> pageResult = statsService.statsByLevel(dto,page-1,limit);
        return pageResult;
    }

    /**
     * 课程顾问统计
     * @return
     */
    @GetMapping("/statsAdviser")
    @ResponseBody
    public PageResult<AdviserResultDTO> statsAdviser(AdviserParamDTO paramDTO,
                                                     @RequestParam(defaultValue = "1") int page,
                                                     @RequestParam(defaultValue = "10") int limit) {
        PageResult<AdviserResultDTO> resultDTOPageResult = statsService.statsAdviser(paramDTO,page-1,limit);
        return resultDTOPageResult;
    }
    /**营收统计
     * @param dto
     * @param page
     * @param limit
     * @return
     */
    @GetMapping("/statsIncome")
    @ResponseBody
    public PageResult<IncomeResultDTO> statsIncome(IncomeParamDTO dto,
                                                            @RequestParam(defaultValue = "1") int page,
                                                            @RequestParam(defaultValue = "10") int limit) {
        PageResult<IncomeResultDTO> pageResult = statsService.statsIncome(dto,page-1,limit);
        return pageResult;
    }
}
